﻿using System;
using System.Web.UI.WebControls;

public partial class aspx_admin_image : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            int id = int.Parse((e.Item.FindControl("图片IDLabel") as Label).Text);
            string filename = "";
            using (ds_名师讲堂TableAdapters.tb_滚动图片TableAdapter da = new ds_名师讲堂TableAdapters.tb_滚动图片TableAdapter())
            {
                filename = (da.GetDataBy图片ID(id).Rows[0] as ds_名师讲堂.tb_滚动图片Row).虚目录;
                WebHelper.FileAndDirectory.DeleteFile(filename);
                da.Delete(id);
            }
            Response.Redirect("image.aspx");
        }
    }

    protected void InsertButton_Click(object sender, EventArgs e)
    {
        if (fu.HasFile)
        {
            string filename = string.Format("{0}{1}", Guid.NewGuid().ToString(), System.IO.Path.GetExtension(fu.FileName));
            WebHelper.WebControls.UploadFile(
                 fu,
                 "~/images/gun/",
                 new string[] { ".jpg", ".png", ".gif", ".jpeg", ".bmp" },
                 filename,
                 false,
                 int.MaxValue);
            using (ds_名师讲堂TableAdapters.tb_滚动图片TableAdapter da = new ds_名师讲堂TableAdapters.tb_滚动图片TableAdapter())
            {
                da.Insert("~/images/gun/" + filename,txt链接.Text,txt显示文本.Text);
            }
            Response.Redirect("image.aspx");
        }
    }
}